package com.study;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.Environment;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;

/**
 * @author zhuzi
 * 2024/6/3 9:17
 */
public class DateDemo {

    @Test
    public void val() {
        // 手动创建 ApplicationContext
        ApplicationContext context = new AnnotationConfigApplicationContext();
        // 获取 Environment 对象
        Environment env = context.getEnvironment();
        // 读取配置文件中的值
        String value = env.getProperty("myname");

        System.out.println("配置文件中的值: " + value);
    }

    @Test
    public void date() {
        LocalDate localDate1 = LocalDate.parse("2024-10-08").plusDays(60);
        System.out.println(localDate1);
        LocalDate now = LocalDate.now();
        ArrayList<String> list = Lists.newArrayList();
        for (int i = 0; i < 12; i++) {
            LocalDate localDate = now.minusMonths(i);
            String format = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
            boolean add = list.add(StrUtil.format("'{}'", format));
        }

        System.out.println(list);
        Collections.reverse(list);//降序
        System.out.println(list);
    }

    @Test
    public void ids() {
        //
        String str = "insert into BUS_RECD_VIRTUAL_VEHICLE_HIS (ID,  VEHICLE_NO,VEHICLE_COLOR_NAME,  VEHICLE_PROPERTIES_CODE, VEHICLE_MODEL_NAME, VEHICLE_NATIONALITY_CODE, VEHICLE_WEIGHT,  AGENCY_ENT_ID, AGENCY_ENT_NAME,  CUSTOMS_CODE, CUSTOMS_NAME, STATUS, CREATE_TIME, CREATOR_ID, CREATOR_NAME)values\n" +
                " ('{}', 'XUNI{}', '白色', '100901', 'XUNI', '100501', 10000.00, '413b9c1b6e4d42048561377a60043484', '满洲里公路口岸物业服务有限责任公司', '0603', '满十八里', '102407', to_date('22-09-2024 19:03:21', 'dd-mm-yyyy hh24:mi:ss'), '9e13826b63ef46fcbdfc294b42900573', '货代公司车辆备案操作员');";

        ArrayList<String> list = Lists.newArrayList();
        for (int i = 740; i <= 1000; i++) {


            String format = StrUtil.format(str, IdUtil.simpleUUID().toUpperCase(), i);
            System.out.println(format);

        }
    }

    @Test
    public void httpGetSync() {
        String s = HttpUtil.get("");
    }

    @Test
    public void strCompare() {
        String a = "A753PТ797";
        String b = "A753PT797";
        System.out.println(a);
        System.out.println(b);

        System.out.println(StringUtils.equalsAny(a, b));
        System.out.println(StringUtils.equalsAnyIgnoreCase(a, b));
        System.out.println(StringUtils.equalsIgnoreCase(a, b));

    }
}
